import json

#将人工标注数据转化为标准格式json
def format_label():
    with open('./data/标注.txt', 'r', encoding='utf-8') as f:
        data = f.readlines()
        for i in data:
            if i =='\n':
                continue
            tag,sentence = i.replace('\n','').split('\t')   #后续要考虑嵌套复句，即一个句子既并列又转折。
            type_d = {'并列':0,'因果':0,'转折':0,'条件':0,}
            type_d[tag] = 10
            with open('./data/标注output.json', 'a+', encoding='utf-8') as f:
                sentence_d = {'text': sentence, 'flag': None, 'type': None,'label':type_d}
                text = json.dumps(sentence_d, ensure_ascii=False)
                f.write(text)
                f.write('\n\n')

if __name__ == '__main__':
    format_label()